<template>
  <div class="app-container">
<el-form ref="form" :model="userInfo" label-width="80px">
  <el-form-item label="用户昵称">
    <el-input v-model="userInfo.userName"></el-input>
  </el-form-item>
  <el-form-item label="用户类型">
    <el-select v-model="userInfo.userType" placeholder="请选择用户类型">
      <el-option label="系统用户" value="00"></el-option>
      <el-option label="普通用户" value="01"></el-option>
    </el-select>
  </el-form-item>
    <el-form-item label="用户邮箱">
    <el-input v-model="userInfo.email"></el-input>
  </el-form-item>
      <el-form-item label="用户手机">
    <el-input v-model="userInfo.phoneNumber"></el-input>
  </el-form-item>
  <el-form-item label="用户生日">
    <el-col :span="11">
      <el-date-picker type="date" placeholder="选择日期" v-model="userInfo.birthday" style="width: 100%;"></el-date-picker>
    </el-col>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="addUserInfo">修改信息</el-button>
    <el-button @click="dialogVisible = false">取消</el-button>
  </el-form-item>
</el-form>
  </div>
</template>
<script>
    import userInfoApi from '@/api/user/userInfo'
  
  export default {
    data() {
      return {
        userInfo: {
          userName: '',
          userType: '',
          email: '',
          phoneNumber: '',
          status: true,
          birthday: ''
        },
        dialogVisible: false
      }
      
    },
    created() {
       this.fetchData();
    },
    methods: {
    fetchData() {
       let roleId= this.$route.params.id == ':id' ? 1: this.$route.params.id
       userInfoApi.show(roleId).then(result => {
          const userInfo = result.data
          this.userInfo = userInfo
        })
      },
      addUserInfo() {
        userInfoApi.saveOrUpdate(this.userInfo).then((response)=>{
        this.$message.success(response.message || '操作成功')
        this.dialogVisible = false
        this.fetchData()
        })
      }
    }
    
  }
</script>